package com.wyh.book.service;

import com.wyh.book.enums.BookStatusEnum;
import com.wyh.book.mapper.BookInfoMapper;
import com.wyh.book.model.BookInfo;
import com.wyh.book.model.PageInfo;
import com.wyh.book.model.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2025-07-12
 * Time: 21:43
 */
@Service
public class PageService {
    @Autowired
    private BookInfoMapper bookInfoMapper;

    public ResponseResult getListByPage(PageInfo pageInfo){
        Integer count = bookInfoMapper.getCount();
        List<BookInfo> bookInfos = bookInfoMapper.getListByPage(pageInfo);
        for (BookInfo bookInfo : bookInfos){
            bookInfo.setStatusCN(BookStatusEnum.getStatusByCode(bookInfo.getStatus()).getDesc());
        }
        return new ResponseResult(count,bookInfos,pageInfo);
    }
}
